/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vista.cotizacion;

import controlador.cotizacion.GestorExplorarSubObras;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Date;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import modelo.Cotizacion;
import util.FechaUtil;
import util.SwingPanel;
import util.TablaUtil;
import util.Tupla;
import vista.comer.pantallaConsultarObra;
import vista.interfaces.ICallBack_v2;
import vista.interfaces.IPermiteCrearSubObra;
import vista.planificacion.EditarPlanificacion;

/**
 *
 * @author iuga
 */
public class ExplorarSubObras extends javax.swing.JInternalFrame implements ICallBack_v2,IPermiteCrearSubObra{

    private GestorExplorarSubObras gestor;
    private int cotizacionId;
    private String estadoCotizacion;
    
    
    /** Creates new form pantallaExplorarAlfonsinas */
    public ExplorarSubObras(int cot_id)
    {
        initComponents();
        
        panelVerPlanificacion.setVisible(false);
        
        gestor = new GestorExplorarSubObras(this);
        gestor.cargarCotizacion(cot_id);
        
        this.cotizacionId = cot_id;
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblMenu = new javax.swing.JTable();
        btnNuevaSubObra = new javax.swing.JButton();
        btnEliminarSubObra = new javax.swing.JButton();
        btnEditarSubObra = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        lblMontoTotal = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel7 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        cmbLVP = new com.toedter.calendar.JDateChooser();
        jLabel19 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        cmbLEP = new com.toedter.calendar.JDateChooser();
        txtNroCotizacion = new javax.swing.JTextField();
        txtPlazoEntrega = new javax.swing.JTextField();
        txtLugarEntrega = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtEstado = new javax.swing.JTextField();
        txtRevision = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        btnCheckCot = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        lbl_obra_planta = new javax.swing.JLabel();
        lbl_obra_nombre = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        lbl_obra_lugar = new javax.swing.JLabel();
        lbl_obra_montomax = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        lbl_obra_fechaini = new javax.swing.JLabel();
        lbl_obra_fechafin = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        panelContenedor = new javax.swing.JPanel();
        panelGraficos = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        lbl_est_titulo_barra = new javax.swing.JLabel();
        prog_est_max = new javax.swing.JProgressBar();
        panelGraficoRecursos = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        _containerGraficoRecursos = new javax.swing.JPanel();
        graficoTortaRecursos = new javax.swing.JPanel();
        panelGraficoSubObras = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        _containerGraficoTortaSubObras = new javax.swing.JPanel();
        graficoTortalSO = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtDescripcionObra = new javax.swing.JTextArea();
        jPanel11 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        btnPlanificar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        btnRecotizar = new javax.swing.JButton();
        btnRechazar = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        btnEnviarCliente = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        panelVerPlanificacion = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        btnAbrirPlanificacion = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Cotización Obra: Montagargas Arco");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Sub-Obras"));
        jPanel3.setMaximumSize(new java.awt.Dimension(50, 50));

        tblMenu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblMenu.setIntercellSpacing(new java.awt.Dimension(10, 5));
        tblMenu.setMaximumSize(new java.awt.Dimension(300, 300));
        tblMenu.setRowHeight(25);
        tblMenu.setTableHeader(null);
        tblMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblMenuMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblMenu);

        btnNuevaSubObra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/add.png"))); // NOI18N
        btnNuevaSubObra.setToolTipText("Nueva SubObra");
        btnNuevaSubObra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevaSubObraActionPerformed(evt);
            }
        });

        btnEliminarSubObra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/delete.png"))); // NOI18N
        btnEliminarSubObra.setToolTipText("Eliminar SubObra");
        btnEliminarSubObra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarSubObraActionPerformed(evt);
            }
        });

        btnEditarSubObra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Modify.png"))); // NOI18N
        btnEditarSubObra.setToolTipText("Modificar la SubObra seleccionada (Otra Forma: Doble click en una SubObra)");
        btnEditarSubObra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarSubObraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(btnNuevaSubObra)
                .addGap(2, 2, 2)
                .addComponent(btnEliminarSubObra)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                .addComponent(btnEditarSubObra, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnNuevaSubObra)
                    .addComponent(btnEliminarSubObra)
                    .addComponent(btnEditarSubObra)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Monto Total de la Obra"));
        jPanel2.setMaximumSize(new java.awt.Dimension(32767, 300));

        lblMontoTotal.setBackground(new java.awt.Color(251, 250, 241));
        lblMontoTotal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblMontoTotal.setText("$2500 ( Max: $3000 )");
        lblMontoTotal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(252, 239, 161)));
        lblMontoTotal.setOpaque(true);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblMontoTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblMontoTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Generales / Estadisticas"));

        jTabbedPane1.setMaximumSize(new java.awt.Dimension(487, 479));

        jPanel7.setMaximumSize(new java.awt.Dimension(487, 479));

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        cmbLVP.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cmbLVPFocusLost(evt);
            }
        });

        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel19.setText("Validez de la Oferta:");

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel18.setText("Fecha Límite de Entrega de la Cotización:");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel14.setText("Número de Cotización:");
        jLabel14.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        cmbLEP.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cmbLEPFocusLost(evt);
            }
        });

        txtNroCotizacion.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtNroCotizacion.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtNroCotizacion.setText("P0000-0000000");
        txtNroCotizacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNroCotizacionActionPerformed(evt);
            }
        });
        txtNroCotizacion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtNroCotizacionFocusLost(evt);
            }
        });

        txtPlazoEntrega.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtPlazoEntregaFocusLost(evt);
            }
        });

        txtLugarEntrega.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtLugarEntregaFocusLost(evt);
            }
        });

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel1.setText("Plazo de Entrega:");

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText("Lugar de Entrega:");

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel3.setText("Estado:");

        txtEstado.setEditable(false);
        txtEstado.setEnabled(false);

        txtRevision.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtRevision.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtRevision.setText("0");
        txtRevision.setEnabled(false);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setText("Revisión:");

        btnCheckCot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/accept.png"))); // NOI18N

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(104, 104, 104)
                                .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                                .addGap(65, 65, 65)
                                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(104, 104, 104)
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)))
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtRevision, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbLVP, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                    .addComponent(cmbLEP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtPlazoEntrega, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtLugarEntrega, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEstado, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                        .addComponent(txtNroCotizacion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCheckCot, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnCheckCot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtNroCotizacion, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtRevision, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbLEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbLVP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPlazoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtLugarEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(8, 8, 8)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel9.setMaximumSize(new java.awt.Dimension(487, 479));
        jPanel9.setPreferredSize(new java.awt.Dimension(487, 479));

        jLabel11.setText("Planta:");

        jLabel16.setText("Monto Máximo:");

        jLabel13.setText("Lugar de la Obra:");

        lbl_obra_planta.setText("BAGLEY S.A.");

        lbl_obra_nombre.setText("Enfriador industrial para ARCOR");
        lbl_obra_nombre.setMaximumSize(new java.awt.Dimension(170, 14));

        jLabel21.setText("Nombre:");

        jLabel22.setFont(new java.awt.Font("Ubuntu", 1, 13)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(123, 166, 189));
        jLabel22.setText("Datos de la Obra");

        lbl_obra_lugar.setText("Córdoba Capital");

        lbl_obra_montomax.setText("$3000");

        jLabel9.setText("Fecha de Inicio:");

        jLabel26.setFont(new java.awt.Font("Ubuntu", 1, 13)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(123, 166, 189));
        jLabel26.setText("Fechas Importantes");

        jLabel29.setText("Fecha de Fin:");

        lbl_obra_fechaini.setText("11/10/2011");

        lbl_obra_fechafin.setText("25/10/2011");

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/search.png"))); // NOI18N
        jButton2.setText("Ver los datos completos de la obra");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel26)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.LEADING))
                                .addGap(49, 49, 49)
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_obra_fechafin, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                    .addComponent(lbl_obra_fechaini, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel22, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(lbl_obra_montomax, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lbl_obra_lugar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lbl_obra_planta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lbl_obra_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(58, 58, 58))
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(lbl_obra_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_obra_planta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(lbl_obra_lugar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(lbl_obra_montomax))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel26)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(lbl_obra_fechaini))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(lbl_obra_fechafin, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 110, Short.MAX_VALUE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Datos Generales", jPanel7);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        panelContenedor.setMaximumSize(new java.awt.Dimension(418, 900));

        panelGraficos.setLayout(new javax.swing.BoxLayout(panelGraficos, javax.swing.BoxLayout.PAGE_AXIS));

        lbl_est_titulo_barra.setFont(new java.awt.Font("Ubuntu", 1, 13)); // NOI18N
        lbl_est_titulo_barra.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_est_titulo_barra.setText("Relación del Monto usado con el Monto máximo");

        prog_est_max.setMaximum(3000);
        prog_est_max.setValue(2500);
        prog_est_max.setString("$2500 / $3000");
        prog_est_max.setStringPainted(true);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbl_est_titulo_barra, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(prog_est_max, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lbl_est_titulo_barra)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prog_est_max, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        panelGraficos.add(jPanel4);

        panelGraficoRecursos.setMinimumSize(new java.awt.Dimension(510, 288));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("Contribución de cada 'Tipo de Recurso' al monto Total");

        _containerGraficoRecursos.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout graficoTortaRecursosLayout = new javax.swing.GroupLayout(graficoTortaRecursos);
        graficoTortaRecursos.setLayout(graficoTortaRecursosLayout);
        graficoTortaRecursosLayout.setHorizontalGroup(
            graficoTortaRecursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 550, Short.MAX_VALUE)
        );
        graficoTortaRecursosLayout.setVerticalGroup(
            graficoTortaRecursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 246, Short.MAX_VALUE)
        );

        _containerGraficoRecursos.add(graficoTortaRecursos, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout panelGraficoRecursosLayout = new javax.swing.GroupLayout(panelGraficoRecursos);
        panelGraficoRecursos.setLayout(panelGraficoRecursosLayout);
        panelGraficoRecursosLayout.setHorizontalGroup(
            panelGraficoRecursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelGraficoRecursosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelGraficoRecursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(_containerGraficoRecursos, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelGraficoRecursosLayout.setVerticalGroup(
            panelGraficoRecursosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelGraficoRecursosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(_containerGraficoRecursos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panelGraficos.add(panelGraficoRecursos);

        panelGraficoSubObras.setMinimumSize(new java.awt.Dimension(510, 288));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Contribución de cada 'Sub-Obra' al monto Total");

        _containerGraficoTortaSubObras.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout graficoTortalSOLayout = new javax.swing.GroupLayout(graficoTortalSO);
        graficoTortalSO.setLayout(graficoTortalSOLayout);
        graficoTortalSOLayout.setHorizontalGroup(
            graficoTortalSOLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 550, Short.MAX_VALUE)
        );
        graficoTortalSOLayout.setVerticalGroup(
            graficoTortalSOLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 246, Short.MAX_VALUE)
        );

        _containerGraficoTortaSubObras.add(graficoTortalSO, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout panelGraficoSubObrasLayout = new javax.swing.GroupLayout(panelGraficoSubObras);
        panelGraficoSubObras.setLayout(panelGraficoSubObrasLayout);
        panelGraficoSubObrasLayout.setHorizontalGroup(
            panelGraficoSubObrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelGraficoSubObrasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelGraficoSubObrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(_containerGraficoTortaSubObras, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelGraficoSubObrasLayout.setVerticalGroup(
            panelGraficoSubObrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelGraficoSubObrasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(_containerGraficoTortaSubObras, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panelGraficos.add(panelGraficoSubObras);

        javax.swing.GroupLayout panelContenedorLayout = new javax.swing.GroupLayout(panelContenedor);
        panelContenedor.setLayout(panelContenedorLayout);
        panelContenedorLayout.setHorizontalGroup(
            panelContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelContenedorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelGraficos, javax.swing.GroupLayout.DEFAULT_SIZE, 570, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelContenedorLayout.setVerticalGroup(
            panelContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelContenedorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelGraficos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jScrollPane2.setViewportView(panelContenedor);

        jTabbedPane1.addTab("Gráficos", jScrollPane2);

        txtDescripcionObra.setColumns(20);
        txtDescripcionObra.setFont(new java.awt.Font("Verdana", 0, 10)); // NOI18N
        txtDescripcionObra.setLineWrap(true);
        txtDescripcionObra.setRows(5);
        txtDescripcionObra.setText("Por la presente cotizamos ...");
        txtDescripcionObra.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDescripcionObraFocusLost(evt);
            }
        });
        jScrollPane3.setViewportView(txtDescripcionObra);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Descripición de la Cotización", jPanel6);

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Acciones con la Cotización"));

        jLabel7.setText("- Mi cliente acepto esta cotización:");

        btnPlanificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Play.png"))); // NOI18N
        btnPlanificar.setText("Comenzar una planificación sobre esta cotización");
        btnPlanificar.setActionCommand("Comenzar una planificación desde esta cotización");
        btnPlanificar.setEnabled(false);
        btnPlanificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPlanificarActionPerformed(evt);
            }
        });

        jLabel8.setText("- Mi cliente no acepto la cotización:");

        btnRecotizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Previous record.png"))); // NOI18N
        btnRecotizar.setText("Recotizar a partir de esta cotización");
        btnRecotizar.setActionCommand("Recotizar desde esta cotización");
        btnRecotizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRecotizarActionPerformed(evt);
            }
        });

        btnRechazar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Stop.png"))); // NOI18N
        btnRechazar.setText("Rechazar cotización");
        btnRechazar.setActionCommand("Recotizar desde esta cotización");
        btnRechazar.setEnabled(false);
        btnRechazar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRechazarActionPerformed(evt);
            }
        });

        jLabel6.setText("¿Desea enviar al cliente esta cotización?");

        btnEnviarCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Target.png"))); // NOI18N
        btnEnviarCliente.setText("Marcar esta cotización como enviada a un cliente y en espera de aceptación");
        btnEnviarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEnviarClienteActionPerformed(evt);
            }
        });

        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Up-down.png"))); // NOI18N

        jLabel24.setText("- Otras Acciones sobre ésta Cotización:");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPlanificar, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(btnEnviarCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(btnRechazar, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(btnRecotizar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEnviarCliente)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addGap(8, 8, 8)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPlanificar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRechazar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel24)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRecotizar))
        );

        panelVerPlanificacion.setBorder(javax.swing.BorderFactory.createTitledBorder("Planificación de esta cotizacion"));

        jLabel15.setText("Deseo Abrir la Planificación para esta Obra:");

        btnAbrirPlanificacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/chart.png"))); // NOI18N
        btnAbrirPlanificacion.setText("Abrir Planificación");
        btnAbrirPlanificacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAbrirPlanificacionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelVerPlanificacionLayout = new javax.swing.GroupLayout(panelVerPlanificacion);
        panelVerPlanificacion.setLayout(panelVerPlanificacionLayout);
        panelVerPlanificacionLayout.setHorizontalGroup(
            panelVerPlanificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelVerPlanificacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelVerPlanificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnAbrirPlanificacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelVerPlanificacionLayout.setVerticalGroup(
            panelVerPlanificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelVerPlanificacionLayout.createSequentialGroup()
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAbrirPlanificacion))
        );

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelVerPlanificacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelVerPlanificacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(214, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Opciones de la Cotización", jPanel11);

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel17.setText("Cotización:");

        jLabel20.setText("<HTML>El objetivo de éste módulo es crear, modificar o dar de baja tantas cotizaciones de la obra como se crean necesarias, dando la flexibilidad y posibilidad de generar propuestas diversas y que cubren distintos aspectos, materiales o formas de trabajo.\nPara simplificar y agilizar este proceso, el sistema de la opción para generar una cotización a partir de otra que se haya realizado anteriormente para otra obra, esto permite reutilizar conocimiento y agilizar la cotización.");

        jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/workflow/Workflow-Cotizacion.png"))); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel23)
                .addContainerGap(274, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("<HTML><span color='002EB8'><b>Ayuda?</b></span>", jPanel5);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
        );

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/List.png"))); // NOI18N
        jButton1.setText("Generar Cotización");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/block.png"))); // NOI18N
        btnCancelar.setText("Cerrar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/iconos/var/16x16/Save.png"))); // NOI18N
        btnSave.setText("Guardar");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(199, 199, 199)
                        .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancelar))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCancelar)
                            .addComponent(jButton1)
                            .addComponent(btnSave))))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        cerrarVentana();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void cerrarVentana()
    {
        if(gestor.isNecesitaGuardar())   
        {
            int btn = JOptionPane.showConfirmDialog(this,"¿Desea Guardar los cambios antes de cerrar?","Atención",JOptionPane.YES_NO_OPTION);
            switch(btn)
            {
                case JOptionPane.YES_OPTION:
                        if(txtNroCotizacion.getText().equals("P0000-0000000A"))
                        {
                            int n = JOptionPane.showConfirmDialog(this,"El número de la cotización es P0000-0000000A ¿Está seguro que no desea cambiarlo? '","Atención!",JOptionPane.YES_NO_OPTION);

                            if(n==JOptionPane.NO_OPTION)
                            {
                                    guardarCotizacion();
                            }
                        }
                        else
                        {
                            guardarCotizacion();    
                        }
                    this.dispose();
                    break;
                case JOptionPane.NO_OPTION:
                    this.dispose();
                    break;
            }
        }
        else
        {
            this.dispose();
        }
    }

   
    private void btnEditarSubObraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarSubObraActionPerformed

        if(tblMenu.getSelectedRow()!=-1)
        {
            DefaultTableModel modelo = (DefaultTableModel)tblMenu.getModel();
            Tupla tp = (Tupla)modelo.getValueAt(tblMenu.getSelectedRow(), 0);
            EditarCotizacion mod = new EditarCotizacion(gestor.getGestorEditarCotizacion(tp.getId()));
            if(tblMenu.getSelectedRow() >=0)
                mod.setTitle("Editar Cotización: "+modelo.getValueAt(tblMenu.getSelectedRow(), 0));
            else
                mod.setTitle("Editar Cotización: Default");
            SwingPanel.getInstance().addWindow(mod);
            mod.setVisible(true);
        }
        else
        {
            JOptionPane.showMessageDialog(this,"Seleccione una sub-obra para modificar sus recursos","Atención!",JOptionPane.QUESTION_MESSAGE);
        }
    }//GEN-LAST:event_btnEditarSubObraActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

//        if(this.estadoCotizacion.equals("En Creacion"))
//        {
//            int btn = JOptionPane.showConfirmDialog(this,"Para que el reporte muestre los datos actualizados, necesita guardar la cotización antes de continuar\n¿Desea Guardar y Continuar?","Atención",JOptionPane.YES_NO_OPTION);
//            switch(btn)
//            {
//                case JOptionPane.YES_OPTION:
//                    if(guardarCotizacion())
//                    {
                        GenerarCotizacion gce = new GenerarCotizacion(this.cotizacionId);
                        SwingPanel.getInstance().addWindow(gce);
                        gce.setVisible(true);
//                    }
//                    break;
//                case JOptionPane.NO_OPTION:
//                    break;
//            }
//        }
        
}//GEN-LAST:event_jButton1ActionPerformed

    private void btnNuevaSubObraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevaSubObraActionPerformed

        CotizacionNuevaSubObra nso = new CotizacionNuevaSubObra(this,CotizacionNuevaSubObra.TIPO_CREAR);
        SwingPanel.getInstance().addWindow(nso);
        nso.setVisible(true);

    }//GEN-LAST:event_btnNuevaSubObraActionPerformed

    private void tblMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblMenuMouseClicked

        if(evt.getClickCount()>=2 && this.estadoCotizacion!=null && this.estadoCotizacion.equals("En Creacion"))
        {
            DefaultTableModel modelo = (DefaultTableModel)tblMenu.getModel();
            
            Tupla tp = (Tupla)modelo.getValueAt(tblMenu.getSelectedRow(), 0);
            EditarCotizacion mod = new EditarCotizacion(gestor.getGestorEditarCotizacion(tp.getId()));
            
            if(tblMenu.getSelectedRow() >=0)
                mod.setTitle("Editar Sub-obra: "+modelo.getValueAt(tblMenu.getSelectedRow(), 0));
            else
                mod.setTitle("Editar Sub-obra: Default");
            SwingPanel.getInstance().addWindow(mod);
            mod.setVisible(true);
        }
        else if(evt.getClickCount()==1 && this.estadoCotizacion!=null && this.estadoCotizacion.equals("En Creacion"))
        {
            if(tblMenu.getSelectedRowCount()!=0)
            {
                btnEditarSubObra.setEnabled(true);
                btnEliminarSubObra.setEnabled(true);
            }
            else
            {
                btnEditarSubObra.setEnabled(false);
                btnEliminarSubObra.setEnabled(false);
            }
        }
    }//GEN-LAST:event_tblMenuMouseClicked

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        pantallaConsultarObra pco = new pantallaConsultarObra(gestor.getObra().getId());
        SwingPanel.getInstance().addWindow(pco);
        pco.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

private void btnEliminarSubObraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarSubObraActionPerformed

    if(tblMenu.getSelectedRow()!=-1)
    {
        DefaultTableModel modelo = (DefaultTableModel)tblMenu.getModel();
        Tupla t = (Tupla)modelo.getValueAt(tblMenu.getSelectedRow(),0);
    
        int n = JOptionPane.showConfirmDialog(this,"¿Realmente desea eliminar la SubObra '"+t.getNombre()+"' y todo su contenido?","Está Seguro?",JOptionPane.YES_NO_OPTION);
    
        if(n==JOptionPane.YES_OPTION)
        {
            gestor.eliminarSubObra(t.getId());
        }
    }
    else
    {
        JOptionPane.showMessageDialog(this,"Seleccione una SubObra para eliminar","Atencion!",JOptionPane.QUESTION_MESSAGE);
    }
}//GEN-LAST:event_btnEliminarSubObraActionPerformed

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed

      /*  if(txtNroCotizacion.getText().equals("P0000-0000000"))
        {
            JOptionPane.showMessageDialog(new JInternalFrame(),"Debe ingresar un número de Cotización para continuar", "Atencion!",JOptionPane.ERROR_MESSAGE);
        }
        else*
        {*/
            int nx = JOptionPane.showConfirmDialog(this,"¿Realmente desea guardar los cambios en la Cotización? '","Está Seguro?",JOptionPane.YES_NO_OPTION);

            if(nx==JOptionPane.YES_OPTION)
            {
                guardarCotizacion();
            }        
      /*  }*/
    
}//GEN-LAST:event_btnSaveActionPerformed

private void txtNroCotizacionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNroCotizacionFocusLost
    gestor.updateNroCotizacion(txtNroCotizacion.getText());
}//GEN-LAST:event_txtNroCotizacionFocusLost

private void cmbLEPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbLEPFocusLost
    gestor.updateLEP(cmbLEP.getDate());
}//GEN-LAST:event_cmbLEPFocusLost

private void cmbLVPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbLVPFocusLost
    gestor.updateLVP(cmbLVP.getDate());
}//GEN-LAST:event_cmbLVPFocusLost

private void txtPlazoEntregaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPlazoEntregaFocusLost
    gestor.updatePlazoEntrega(txtPlazoEntrega.getText());
}//GEN-LAST:event_txtPlazoEntregaFocusLost

private void txtLugarEntregaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtLugarEntregaFocusLost
    gestor.updateLugarEntrega(txtLugarEntrega.getText());
}//GEN-LAST:event_txtLugarEntregaFocusLost

private void txtDescripcionObraFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDescripcionObraFocusLost
    gestor.updateDescripcion(txtDescripcionObra.getText());// TODO add your handling code here:
}//GEN-LAST:event_txtDescripcionObraFocusLost

private void btnRechazarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRechazarActionPerformed

    rechazarCotizacion();
    
}//GEN-LAST:event_btnRechazarActionPerformed

    private void btnEnviarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEnviarClienteActionPerformed
      enviarCotizacionCliente();
    }//GEN-LAST:event_btnEnviarClienteActionPerformed

private void btnRecotizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRecotizarActionPerformed
        
        int nuevoId=gestor.recotizar(this);               
                     
        
        if(nuevoId<0)
        {
         JOptionPane.showMessageDialog(this.getParent(),"Ocurrió un error en el registro de la nueva cotización","Error",JOptionPane.ERROR_MESSAGE);
        }
        else
        {
          ExplorarSubObras mod =  new ExplorarSubObras(nuevoId);
          SwingPanel.getInstance().addWindow(mod);
          mod.setVisible(true);
          this.dispose();
        }
}//GEN-LAST:event_btnRecotizarActionPerformed

    private void txtNroCotizacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNroCotizacionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNroCotizacionActionPerformed

    private void btnPlanificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlanificarActionPerformed
        
        gestor.comenzarPlaificacion();
   
    }//GEN-LAST:event_btnPlanificarActionPerformed

    public void lanzarPlanificacion(int idObra)
    {
        // Si no exploto hasta ahora, lanzo la nueva ventana
        EditarPlanificacion win = new EditarPlanificacion(EditarPlanificacion.TEMPLATE_MODIFICACION,idObra);
        SwingPanel.getInstance().addWindow(win);
        win.setVisible(true);  
        this.dispose();
    }
    
    private void btnAbrirPlanificacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAbrirPlanificacionActionPerformed
        
        int idPlan = gestor.getIdDePlanificacionDeObra();
        if(idPlan!=0)
        {
            EditarPlanificacion ep = new EditarPlanificacion(1,idPlan);
            SwingPanel.getInstance().addWindow(ep);
            ep.setVisible(true);
            this.dispose();
        }
        else
        {
            JOptionPane.showMessageDialog(new JInternalFrame(),"No se encontro la planificacion asociada", "Error!",JOptionPane.ERROR_MESSAGE);
        }
        
    }//GEN-LAST:event_btnAbrirPlanificacionActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel _containerGraficoRecursos;
    private javax.swing.JPanel _containerGraficoTortaSubObras;
    private javax.swing.JButton btnAbrirPlanificacion;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnCheckCot;
    private javax.swing.JButton btnEditarSubObra;
    private javax.swing.JButton btnEliminarSubObra;
    private javax.swing.JButton btnEnviarCliente;
    private javax.swing.JButton btnNuevaSubObra;
    private javax.swing.JButton btnPlanificar;
    private javax.swing.JButton btnRechazar;
    private javax.swing.JButton btnRecotizar;
    private javax.swing.JButton btnSave;
    private com.toedter.calendar.JDateChooser cmbLEP;
    private com.toedter.calendar.JDateChooser cmbLVP;
    private javax.swing.JPanel graficoTortaRecursos;
    private javax.swing.JPanel graficoTortalSO;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblMontoTotal;
    private javax.swing.JLabel lbl_est_titulo_barra;
    private javax.swing.JLabel lbl_obra_fechafin;
    private javax.swing.JLabel lbl_obra_fechaini;
    private javax.swing.JLabel lbl_obra_lugar;
    private javax.swing.JLabel lbl_obra_montomax;
    private javax.swing.JLabel lbl_obra_nombre;
    private javax.swing.JLabel lbl_obra_planta;
    private javax.swing.JPanel panelContenedor;
    private javax.swing.JPanel panelGraficoRecursos;
    private javax.swing.JPanel panelGraficoSubObras;
    private javax.swing.JPanel panelGraficos;
    private javax.swing.JPanel panelVerPlanificacion;
    private javax.swing.JProgressBar prog_est_max;
    private javax.swing.JTable tblMenu;
    private javax.swing.JTextArea txtDescripcionObra;
    private javax.swing.JTextField txtEstado;
    private javax.swing.JTextField txtLugarEntrega;
    private javax.swing.JTextField txtNroCotizacion;
    private javax.swing.JTextField txtPlazoEntrega;
    private javax.swing.JTextField txtRevision;
    // End of variables declaration//GEN-END:variables

    public void updateGraphs()
    {
        updateGraphTortaSubObras();
        initGraphTortaItems();
    }

    private void updateGraphTortaSubObras()
    {
        // Limpio
        _containerGraficoTortaSubObras.remove(((BorderLayout)_containerGraficoTortaSubObras.getLayout()).getLayoutComponent(BorderLayout.CENTER));
        // Cargo
        graficoTortalSO = new CotizacionGraficoTortaSubObras(gestor.getDataGraficoSubObras());
        _containerGraficoTortaSubObras.add(graficoTortalSO,BorderLayout.CENTER);
        _containerGraficoTortaSubObras.validate();
        panelGraficos.repaint();
        pack();
    }

    private void initGraphTortaItems() 
    {
        // Limpio
        _containerGraficoRecursos.remove(((BorderLayout)_containerGraficoRecursos.getLayout()).getLayoutComponent(BorderLayout.CENTER));
        //Cargo
        graficoTortaRecursos = new CotizacionGraficoTortaSubObras(gestor.getDataGraficoRecursos());
        _containerGraficoRecursos.add(graficoTortaRecursos,BorderLayout.CENTER);
        _containerGraficoRecursos.validate();
        panelGraficos.repaint();
        pack();
    }
    
    public void cargarSubObras(Tupla t)
    {
        DefaultTableModel modelo = (DefaultTableModel) tblMenu.getModel();
        Object[] fila = new Object[1];
        fila[0] = t;
        modelo.addRow(fila);
    }
    
    public void llenarDatosGeneralesObra(String nombre, String planta, String lugar, String monto_max, String fecha_ini, String fecha_fin)
    {
        lbl_obra_nombre.setText(nombre);
        lbl_obra_planta.setText(planta);
        lbl_obra_lugar.setText(lugar);
        lbl_obra_montomax.setText(monto_max);
        lbl_obra_fechaini.setText(fecha_ini);
        lbl_obra_fechafin.setText(fecha_fin);
    }
    
    public void llenarDatosCotizacion(String nroCotizacion, int revision ,Date fle,Date vo, String plazoEntrega, String lugarEntrega, String estado)
    {
        if(nroCotizacion==null || nroCotizacion.isEmpty())
        {
            txtNroCotizacion.setText("P0000-0000000");
            txtNroCotizacion.setEnabled(true);
            btnCheckCot.setEnabled(true);
            setNroCotizacionInvalido();
        }
        else
        {
            txtNroCotizacion.setText(nroCotizacion);
            txtNroCotizacion.setEnabled(false);
            btnCheckCot.setEnabled(false);
            setNroCotizacionValido();
        }
        
        txtRevision.setText(""+revision);
        cmbLEP.setDate(fle);
        cmbLVP.setDate(vo);
        txtPlazoEntrega.setText(plazoEntrega);
        txtLugarEntrega.setText(lugarEntrega);
        txtEstado.setText(estado);
    }    
    
    public void setMontoTotal(String monto)
    {
        lblMontoTotal.setText(monto);
    }

    public void setMontoActualVSMaximo(double total, double montoMaximo) {
        
        if(montoMaximo!=0)
        {
            lbl_est_titulo_barra.setVisible(true);
            prog_est_max.setVisible(true);
            if(montoMaximo>=total)
            {
                // El monto actual es menor al presupuesto fijado por el cliente
                prog_est_max.setMaximum((int)montoMaximo);
                prog_est_max.setValue((int)total);
                prog_est_max.setForeground(Color.BLACK);
                prog_est_max.setString("$"+total+" / "+"$"+montoMaximo);
            }
            else
            {
                // El monto actual es superior al presupuesto
                prog_est_max.setMaximum(100);
                prog_est_max.setValue(100);
                prog_est_max.setForeground(Color.RED);
                prog_est_max.putClientProperty("background", Color.orange);
                prog_est_max.setString("$"+total+" / "+"$"+montoMaximo+" (Presupuesto excedido por: $"+Math.round(total-montoMaximo)+")");
            }
            
        }
        else
        {
            lbl_est_titulo_barra.setVisible(false);
            prog_est_max.setVisible(false);
        }
        
    }

    public void setDescripcionObra(String descripcion) 
    {
        if(!descripcion.isEmpty())
        {
            txtDescripcionObra.setText(descripcion);
        }
    }
    
    public void crearNuevaSubObra(String nombre)
    {
        gestor.crearSubObra(nombre);
    }

    void modificarNombreSubObra(String nombre) 
    {
        
    }

    public void clearSubObrasList() 
    {
        // Vacio la tabla
        DefaultTableModel modelo = (DefaultTableModel) tblMenu.getModel();
        TablaUtil.vaciarDefaultTableModel(modelo);
    }
    
    public void cambiarNombreSubObra(Tupla tp)
    {
        gestor.cambiarNombreSubObra(tp.getId(),tp.getNombre());
        tblMenu.repaint();
    }

    private boolean guardarCotizacion()
    {
        // TODO: RECORDAR RECOMENTAR ESTAS LINEAS para tener validaciones de líneas
//        if(cmbLVP.getDate()!=null && !FechaUtil.fechaMayorQue(cmbLVP.getDate(),new Date()))
//        {
//            JOptionPane.showMessageDialog(new JInternalFrame(),"La \"Fecha de validez de la Oferta\" debe ser mayor a la fecha actual", "Error!",JOptionPane.ERROR_MESSAGE);
//            return false;
//        }
//        
//        if(cmbLEP.getDate()!=null && !FechaUtil.fechaMayorQue(cmbLEP.getDate(),new Date()))
//        {
//            JOptionPane.showMessageDialog(new JInternalFrame(),"La \"Fecha límite de Entrega de la Cotización\" debe ser mayor a la fecha actual", "Error!",JOptionPane.ERROR_MESSAGE);
//            return false;
//        }        
        
        if(txtNroCotizacion.isEnabled())
        {
            return gestor.guardarCotizacion(true);
        }
        else
        {
            return gestor.guardarCotizacion(false);
        }
    }
    
    /**
     * Muestra un mensaje
     * @param tipo
     * @param titulo
     * @param mensaje 
     */
    public void MostrarMensaje(int tipo,String titulo,String mensaje)
    {
         JOptionPane.showMessageDialog(this.getParent(),mensaje,titulo,tipo);
    }

    private void rechazarCotizacion() 
    {
        gestor.rechazarCotizacion();
    }

    public void setEstadoRechazado() 
    {
        int nx = JOptionPane.showConfirmDialog(this,"Se rechazó la cotización \n¿Desea guardar los cambios? '","Está Seguro?",JOptionPane.YES_NO_OPTION);

            if(nx==JOptionPane.YES_OPTION)
            {
                guardarCotizacion();
            }
    }

    public void refrescarVentanaEstadoRechazado() 
    {
        btnSave.setEnabled(false);
        txtNroCotizacion.setEnabled(false);
        btnCheckCot.setEnabled(false);
        cmbLEP.setEnabled(false);
        cmbLVP.setEnabled(false);
        txtLugarEntrega.setEnabled(false);
        txtDescripcionObra.setEnabled(false);
        txtPlazoEntrega.setEnabled(false);
        
        btnRechazar.setEnabled(false);
        btnPlanificar.setEnabled(false);
        btnRecotizar.setEnabled(false);
        btnEnviarCliente.setEnabled(false);
        
        btnNuevaSubObra.setEnabled(false);
        btnEliminarSubObra.setEnabled(false);
        btnEditarSubObra.setEnabled(false);
        
        panelVerPlanificacion.setVisible(false);
        
        this.estadoCotizacion = "Rechazado";
    }

    public void refrescarVentanaEstadoPendienteAceptacion() 
    {
        btnSave.setEnabled(false);
        txtNroCotizacion.setEnabled(false);
        btnCheckCot.setEnabled(false);
        cmbLEP.setEnabled(false);
        cmbLVP.setEnabled(false);
        txtLugarEntrega.setEnabled(false);
        txtDescripcionObra.setEnabled(false);
        txtPlazoEntrega.setEnabled(false);
        
        btnRechazar.setEnabled(true);
        //btnRecotizar.setEnabled(true);
        btnPlanificar.setEnabled(true);
        btnEnviarCliente.setEnabled(false);
        
        btnNuevaSubObra.setEnabled(false);
        btnEliminarSubObra.setEnabled(false);
        btnEditarSubObra.setEnabled(false);     
        panelVerPlanificacion.setVisible(false);
        
        this.estadoCotizacion = "Pendiente de Aceptacion";
    }

    public void refrescarVentanaEstadoEnCreacion() 
    {
        btnSave.setEnabled(true);
        //txtNroCotizacion.setEnabled(true);
        cmbLEP.setEnabled(true);
        cmbLVP.setEnabled(true);
        txtLugarEntrega.setEnabled(true);
        txtDescripcionObra.setEnabled(true);
        txtPlazoEntrega.setEnabled(true);
        
        btnRechazar.setEnabled(false);
        btnPlanificar.setEnabled(false);
        //btnRecotizar.setEnabled(false);
        btnEnviarCliente.setEnabled(true);
        
        btnNuevaSubObra.setEnabled(true);
        btnEliminarSubObra.setEnabled(false);
        btnEditarSubObra.setEnabled(false);   
        panelVerPlanificacion.setVisible(false);
        
        this.estadoCotizacion = "En Creacion";
    }

    private void enviarCotizacionCliente() 
    {
        gestor.enviarCotizacionCliente();
    }
    
    public boolean guardarAntesDeEnviarAlCliente() 
    {
        int nx = JOptionPane.showConfirmDialog(this,"Esta cotización va a marcarse como enviada al cliente \nPara continuar necesita guardar los cambios realizados\n¿Desea guardar los cambios y continuar?","Está Seguro?",JOptionPane.YES_NO_OPTION);

            if(nx==JOptionPane.YES_OPTION)
            {
               return guardarCotizacion();
            }
            
         return false;
    }

    public void setNroCotizacionInvalido() 
    {
        txtNroCotizacion.setBackground(Color.red);
    }

    public void setNroCotizacionValido() 
    {
        txtNroCotizacion.setBackground(Color.GREEN);
    }

    public void setNroCotizacionValidoGuardado() 
    
    {
        txtNroCotizacion.setBackground(Color.GREEN);
        txtNroCotizacion.setEnabled(false);
        btnCheckCot.setEnabled(false);
    }
    @Override
    public void actualizar(int id, String CU, boolean exito)
    {
        
        if(CU.equals("CopiaCotizacionCambioFechas")&&exito==false)
        {
            JOptionPane.showMessageDialog(this.getParent(),"Las fechas de las tareas en la tareas de la cotización fueron modificadas para adaptarse a las fechas de la obra. \nFavor de verificar las fechas de las tareas","Advertencia",JOptionPane.ERROR_MESSAGE);
        }
        
    }

    public void refrescarVentanaEstadoAceptado() {
        btnSave.setEnabled(false);
        txtNroCotizacion.setEnabled(false);
        btnCheckCot.setEnabled(false);
        cmbLEP.setEnabled(false);
        cmbLVP.setEnabled(false);
        txtLugarEntrega.setEnabled(false);
        txtDescripcionObra.setEnabled(false);
        txtPlazoEntrega.setEnabled(false);
        
        btnRechazar.setEnabled(false);
        //btnRecotizar.setEnabled(true);
        btnPlanificar.setEnabled(false);
        btnEnviarCliente.setEnabled(false);
        
        btnNuevaSubObra.setEnabled(false);
        btnEliminarSubObra.setEnabled(false);
        btnEditarSubObra.setEnabled(false);    
        btnRecotizar.setEnabled(false);
        panelVerPlanificacion.setVisible(true);
        
        this.estadoCotizacion = Cotizacion.ESTADO_ACEPTADO;        
    }

    public Date getFechaLimiteEntrega() {
        return this.cmbLEP.getDate();
    }

    public Date getFechaValidezOferta() {
        return this.cmbLVP.getDate();
    }

    public String getPlazoEntrega() {
        return txtPlazoEntrega.getText();
    }

    public String getLugarEntrega() {
        return txtLugarEntrega.getText();
    }

    public String getDescripcionCotizacion() {
        return txtDescripcionObra.getText();
    }
    
}
